#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
pair<string,string> sx[2000000];
int n=-1;
int main()
{
    freopen("vector.train","r",stdin);
    do{n++;
        cin>>sx[n].second;
        getline(cin,sx[n].first);

    }while(sx[n].first!="");
    sx[n].first="###";
    sx[n].second="-1";
    sort(sx,sx+n);
    for(int i=1;i<n;i++){
        if(sx[i].first==sx[i-1].first&&sx[i-1].second=="+1"){
            sx[i].second="+1";
        }
    }
    sort(sx,sx+n);
    sx[n+1]=sx[n];
    freopen("vector.train","w",stdout);
    for(int i=0;i<n;i++)
    if(sx[i].first!=sx[i+1].first&& sx[i].second=="+1")
    {
        cout<<sx[i].second<<sx[i].first<<endl;
    }
    for(int i=0;i<n;i++)
    if(sx[i].first!=sx[i+1].first&&sx[i].second=="-1")
    {
        cout<<sx[i].second<<sx[i].first<<endl;
    }
}
